{literal}
<script type="text/javascript" language="javascript">
var urlEditar = '{/literal}{$_site.url}{$urlEditar}{literal}';
var urlApagar = '{/literal}{$_site.url}{$urlApagar}{literal}';
function irPara(pag)
{
	document.form_busca.pag.value = pag;
	jqAjaxForm(document.form_busca, "div_tabela");
}
function anterior()
{
	irPara(parseInt(document.form_busca.pag.value)-1);
}
function proximo()
{
	irPara(parseInt(document.form_busca.pag.value)+1);
}
function editar(codigo)
{
	document.form_acao.action = urlEditar;
	document.form_acao.codigo.value = codigo;
	document.form_acao.acao.value = "editar";
	jqAjaxForm(document.form_acao, "div_form");
}
function excluir(codigo)
{
	document.form_acao.action = urlApagar;
	document.form_acao.codigo.value = codigo;
	document.form_acao.acao.value = "apagar";
	jqAjaxForm(document.form_acao, "div_form");
}

$(document).ready(function(){
	$("#cod_cliente").autocomplete("contrato/complete-codigo", {
		width: 400,
		max: 10,
		scroll: false,
		scrollHeight: 500,
		mustMatch:true,
		delay:400,
		formatItem: function(data, i, n, value) {
			return value.split("::")[0]+" - "+value.split("::")[1];
		},
		formatResult: function(data, value) {
			return value.split("::")[0];
		}
	});

	$("#cod_cliente").result(function(event, data, formatted) {
		if (data) {
			$("#contrato_id").val(formatted.split("::")[0]);
			$("#nome_cliente").val(formatted.split("::")[1]);
		}
	});

	//AUTO COMPLETE COM O NOME DE CLIENTES
	$("#nome_cliente").autocomplete("contrato/complete-nome", {
		width: 400,
		max: 10,
		scroll: false,
		scrollHeight: 500,
		mustMatch:true,
		delay:400,
		formatItem: function(data2, i2, n2, value2) {
			return value2.split("::")[0]+"  (Contrato: "+value2.split("::")[1]+")";
		},
		formatResult: function(data2, value2) {
			return value2.split("::")[0];
			 
		}
	});

	$("#nome_cliente").result(function(event2, data2, formatted2) {
		if (data2){
			$("#contrato_id").val(formatted2.split("::")[1]);
			$("#cod_cliente").val(formatted2.split("::")[1]);
		}
	});
    
}); //fecha $(

</script>
{/literal}
	<form name="form_conciliacao" id="form_conciliacao" action="#" method="post">
		<input type="hidden" name="codigo" id="codigo" value=""/>
		<input type="hidden" name="acao" id="acao" value=""/>
	</form>
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="2" class="alpha">
      <tr>
        <td colspan="8" class="mvTituloFundo">Status de cobran&ccedil;as</td>
      </tr>
      <tr>
        <td colspan="8" align="center">
	        <form name="form_busca" id="form_busca" action="{$_site.url}conciliacao-bancaria/tabela" method="post" onsubmit="irPara(document.form_busca.pag.value); return false;">
	        	<table width="100%">
	        		<tr>
	        			<td class="fundoTituloForm bordaFormResp" width="15%">M&ecirc;s/Ano</td>
	        			<td class="bordaFormResp" width="15%"><input type="text" name="mes" id="mes" value="{$mes}" size="2" class="formulario"/>/<input type="text" name="ano" id="ano" value="{$ano}" size="4" class="formulario"/></td>
	        			<td class="fundoTituloForm bordaFormResp" width="15%">Pago</td>
	        			<td class="bordaFormResp" width="55%"><input type="radio" name="pago" id="pago" value="1" class="formulario"/>Sim&nbsp;<input type="radio" name="pago" id="pago" value="0" class="formulario"/>N&atilde;o</td>
	        		</tr>
	 				<tr>
	        			<td class="fundoTituloForm bordaFormResp" width="15%">C&oacute;digo do cliente</td>
                 		<td valign="top" class="bordaFormResp"><input name="cod_cliente" type="text" class="formulario" id="cod_cliente" value="" size="10"/>
                 		<br><input type="hidden" name="contrato_id" id="contrato_id" value=""/>
                 		</td>
	        			<td class="fundoTituloForm bordaFormResp" width="15%">Nome do cliente</td>
                 		<td valign="top" class="bordaFormResp"><input name="nome_cliente" type="text" class="formulario tamanhoForm" id="nome_cliente" value="" size="40"/></td>
					</tr>
	 				<tr>
                 		<td valign="top" class="bordaFormResp" colspan="4" align="center"><input type="submit" value="Buscar" class="botao"/></td>
					</tr>
	        	</table>
				<input type="hidden" name="pag" id="pag" value="{$pag}"/>
			</form>
		</td>
      </tr>
      <tr>
        <td colspan="8" align="center"><b>{$total}</b> encontrados, exibindo de <b>{$inicio}</b> a <b>{$fim}</b></td>
      </tr>
      <tr>
        <td valign="top" width="10%" class="paddingTotal3 bgCarla bold">Cliente</td>
        <td valign="top" width="10%" class="paddingTotal3 bgCarla bold">Extrato</td>
        <td valign="top" width="15%" class="paddingTotal3 bgCarla bold">M&ecirc;s/Ano</td>
        <td valign="top" width="15%" class="paddingTotal3 bgCarla bold">Data de vencimento</td>
        <td valign="top" width="15%" class="paddingTotal3 bgCarla bold">Data de pagamento</td>
        <td valign="top" width="15%" class="paddingTotal3 bgCarla bold">Valor t&iacute;tulo (R$)</td>
        <td valign="top" width="15%" class="paddingTotal3 bgCarla bold">Valor pago (R$)</td>
        <td valign="top" width="5%" class="paddingTotal3 bgCarla bold">Pago</td>
      </tr>
      {foreach name=lista from=$cobrancas item=cobranca}
      <tr>
        <td valign="top" class="fundoTituloForm">{$cobranca->contrato_id}</td>
        <td valign="top" class="fundoTituloForm">{$cobranca->vhr_numextrato}</td>
        <td valign="top" class="fundoTituloForm">{$cobranca->vhr_ano_mes_referencia|substr:4:2|recuperarMesGeracaoExtrato} / {$cobranca->vhr_ano_mes_referencia|substr:0:4}</td>
        <td valign="top" class="fundoTituloForm">{$cobranca->dte_vencimento|ConverteData:5}</td>
        <td valign="top" class="fundoTituloForm">{$cobranca->dte_pagamento|ConverteData:5}</td>
        <td valign="top" class="fundoTituloForm">{$cobranca->flt_valor}</td>
        <td valign="top" class="fundoTituloForm">{if $cobranca->flt_valor!=$cobranca->flt_valorpago}<u>{/if}{$cobranca->flt_valorpago}{if $cobranca->flt_valor!=$cobranca->flt_valorpago}</u>{/if}</td>
        <td width="200" valign="top" class="fundoTituloForm">
        {if $cobranca->bln_pago==1}<font color='blue'>Sim</font>{/if}
        {if $cobranca->bln_pago==0}<font color='red'>N&atilde;o</font>{/if}
        </td>
      </tr>
      {/foreach}
      <tr>
        <td colspan="8" align="center">{if $pag gt 1}
		<a href="#" onclick="irPara('1'); return false;"><<</a> 
		<a href="#" onclick="anterior(); return false;"><</a> 
	{else}
		<<  < 
	{/if}
	{section name=foo start=1 loop=$totalPag+1}
		{if $smarty.section.foo.index eq $pag}
			<font color="red">{$smarty.section.foo.index}</font>
		{else}
			<a href="#" onclick="irPara('{$smarty.section.foo.index}'); return false;">{$smarty.section.foo.index}</a>
		{/if}
		{if $smarty.section.foo.index lt $totalPag}
		|
		{/if}
	{/section}
	{if $pag lt $totalPag}
	<a href="#" onclick="proximo(); return false;">></a> 
	<a href="#" onclick="irPara('{$totalPag}'); return false;">>></a>
	{else}
	>  >>
	{/if}</td>
      </tr>
    </table>
